package com.boer;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SensorComplianceChecker {

    public static List<String> complianceCheck(List<String> sensorIds) {
        List<String> invalidSensors = new ArrayList<>();
        for (String sensorId : sensorIds) {
            sensorId = sensorId.trim();  // 去除多余空格
            if (!isValidSensor(sensorId)) {
                invalidSensors.add(sensorId);
            }
        }
        return invalidSensors;
    }

    private static boolean isValidSensor(String sensorId) {
        if (sensorId == null || sensorId.isEmpty()) {
            return false;
        }
        // 如果传感器包含“?”，只取前面的部分
        if (sensorId.contains("?")) {
            sensorId = sensorId.split("\\?")[0];
        }
        // 转换为大写
        sensorId = sensorId.toUpperCase();
        
        // 检查传感器ID长度是否为8
        if (sensorId.length() != 8) {
            return false;
        }
        
        // 校验传感器ID字符是否在合法范围内
        for (char c : sensorId.toCharArray()) {
            if (c > 'F' && !Character.isDigit(c)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        // 示例数据，使用从图像提取的传感器ID
        List<String> sensorIds = Arrays.asList(
                "C92AF75B","C915A44D","C915463C","C92ADF6E","C92AF879","54CD3ECE","34CD3753","44CD371C","84CD3FB0","44CD3D05","84CD3FBO","81243BE4","81242C09","81242C0C","81243BB5","81242F03","81243C1D","8124349E","81242C0E","8124380E","81243509","81242A3D","81243862","81243188","81242740","812432CB","8124392B","812433C5","81243392","81242E40","81243504","81243A9A","8124339F","81242F06","81242C19","81245355","8124422E","81243A92","81242BDE","51F02FBD","b9c74e","bc466e","bd08a9","bb496f","bba03f","8c3433","92d132","b9b3d8","F4CD2BC1","34CB91CC","84CB918B","54CB8EC2","5ACE01A8","74CB8FC9","84CD38FD","E1EC60C6","5ACDFE1C","84CB98C1","74CB8F48","bad479","E19166A0","E192E751","AACB8408","3ACB7FEB","E18A2513","8ACB71E9","7ACB703F","6ACB6E3D","5ACB6F30","c0375d","E19110A0","E1911386","E18D5B03","E189DDC3","E18B8CE1","E1A2E812","E18C97A1","E1F246E1","E1926C93","E1F2CA83","E18D8653","81136758","E1EA6DD4","812431B4","81243129","81242BD8","81243A48","96B71D5E","96B704C9","9411D8A0","96B71E9A","96B70B7A","97221AD1","84CB8E7D","74CB98C8","34CF15F9","F4CB8FC3","84CF31F4","F4CB911C","E19121D6","81245372","812440E5","81245385","812451F7","8124541E","8124291B","8124408D","812440FD","81244348","81245382","E1F0B7B1","41F0397C","41F03993","41F02E5B","81F02401","A1F025EB","41F03020","81242BC5","81243A77","812426BB","81242712","81243761","81242F88","81135774","81137120","F1F02CB5","A1F02F75","41F03B07","A1F02668","81243050","81243524","812439C5","81243A1D","E0B85A66","E0B85A78","81243FA0","68CE1262","E0B863E6","E0B8596B","E0B87C39","E0B87BCB","E0B85AD2","E0B863A3","E0B859D7","E0B8673C","97255B2F","9673C5CE","972564FC","81244325","34CD3D84","71F0306E","71F02323","41F026A2","41F03215","A1F024EF","41F03A85","81F0243D","81F026BA","97256339","97255EB9","31F02EBE","81F0305B","81F03995","71F02207","81242BC4","8124331C","81242F1B","81242B59","64CF2E1F","3ACE0388","74CF2CBE","48CDFE06","84CD37FD","A1F02AB0","A1F03AC4","78CB874B","9673C537","81242B2E","81242AD0","81135C3E","41F01F4A","81242E77","81242B5B","812432BE","E1EDA0B2","A1F03053","8167E705","31F03080","9411D887","9411D6BE","971D7090","97254E9C","54CD3B07","A1F02E64","97254BCE","97255E2F","51F023BF","51F034F9","81F026E1","78CB860D","81242F7B","81242DF3","8124514C","81243206","81243A5C","812438B0","81243444","E1E91F94","74CB8FB8","C929141A","34CB7C60","54CB8F56","F4CF21BB","5ACD36DD","64CB99B4","34CB8F27","34CF24CB","9411D709","9725444B","97255B50","9725434F","9411D82C","9411D870","972545C4","97254ED8","9725693B","97256934","9411D875","97255B69","81245167","81243903","8124424E","812440CE","81243FD8","81242CC9","8124532E","8124404B","812453DC","81244269","81242F43","81242E95","812442A4","34CD3EC3","64CD3D6A","F4CD356A","48CE1790","44CD35C2","64CD3BBC","84CD3C33","64CD3B04","64CD3E32","64CD411D","84CE0D23","34CD3E10","41F01E16","41F02DF0","68CE02B9","E1E83874","41F03400","A1F03A5A","A1F03AA9","E1ED90E3","F1F03A76","51F03E78","C92C512E","81F01E5B","84CD2B21","34CF2CD3","74CD24AF","34CD3161","64CD2A0F","34CF2883","34CD25AA","74CF306A","972541A8","97254262","97254E3D","9725447B","97254689","97254C9D","64CF3160","34CD21C4","64CF208F","64CF1A7D","54CD2C19","54CF214F","84CF209F","74CB993B","84CF1945","F4CD2F1E","64CF2890","84CD27BF","64CF19FC","74CF1C76","84CD27C1","34CF1E7F","C9182F1A","C9290C2B","C92D711E","C92CF37C","54CD398D","64CD2BC8","74CF3175","34CD2A7F","34CD2B46","74CD277E","54CF28B1","64CD2772","C8B34F7F","44CD269D","44CD3189","84CF2121","F4CD1F9E","74CF1FF0","64CD27E8","74CD2ECF","41F0269E","41F02A1D","71F02F3F","51F03900","F1F02A22","81F03E94","F1F01F81","54CF2AD9","84CF2179","64CF1741","A1F03AB9","91f9b0","b91cd9","bd408d","c01e6d","b8f97f","91d200","bced5d","bb0d9e","9057d2","8d92a4","b908ef","c1078f","bc79af","54CF3298","8113583B","81135C08","54CF28D5","8AD42703","88D4135E","8AD350CB","5AD3524D","6AD385B6","A8D415A9","71F02DC1","31F027EA","31F03B52","31F03A3C","A1F03213","71F01FED","E0B85B29","E0B8687C","E0B863CC","E0B85A74","E0B87BFB","E0B8674A","EOB8674A","81135B3E","812433F5","81136347","48CB884D","54CD3981","64CB7ABA","34CB810A","78CB846B","58CB8680","E0B87BC6","E0B85B61","E0B85ACF","E0B86762","E0B863BE","81242AC2","812433DF","811363AE","34CE0B40","78CE15F0","54CE0D32","84CE09A3","68CE15AD","54CE0F06","78CE15AE","34CE09E8","74CE0D5A","84CE09AA","84CE0E7A","48CE1016","F4CD33C1"
        );


        List<String> invalidSensors = complianceCheck(sensorIds);
        System.out.println("不合规的传感器ID列表: " + JSON.toJSONString(invalidSensors));
    }
}
